package com.example.dyxeapplication.content.menu.ejaan.belajar.kata;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.dyxeapplication.R;
import com.example.dyxeapplication.content.menu.ejaan.belajar.Ejaan_FT;
import com.example.dyxeapplication.content.menu.ejaan.belajar.kata.perhuruf.Kata_F;
import com.example.dyxeapplication.menu.Menu;
import com.example.dyxeapplication.menu.ejaan.Menu_Ejaan_FT;

public class Kata_FT extends Activity implements OnClickListener{
	private Button imgview1, imgview2;
	private MediaPlayer mp;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menu_ejaan_binatang_2);

		Button satu = (Button) findViewById(R.id.satu);
		Button dua = (Button) findViewById(R.id.dua);
		Button tiga = (Button) findViewById(R.id.tiga); 
		
		imgview1 = (Button) findViewById(R.id.b);
		imgview1.setBackgroundResource(R.drawable.foto);

		imgview2 = (Button) findViewById(R.id.d);
		imgview2.setBackgroundResource(R.drawable.tikus);
		
		imgview1.setOnClickListener(this);
		imgview2.setOnClickListener(this);
		
		satu.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(Kata_FT.this, Ejaan_FT.class);
				i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(i);
			}
		});
		
		dua.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(Kata_FT.this, Kata_FT.class);
				i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(i);
			}
		});
		
		tiga.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(Kata_FT.this, Kata_F.class);
				i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(i);
			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (mp != null)
			mp.release();

		if (v.getId() == R.id.b) {
			mp = MediaPlayer.create(this, R.raw.foto);

		} else if (v.getId() == R.id.d) {
			mp = MediaPlayer.create(this, R.raw.tikus);

		} 
		mp.seekTo(0);
		mp.start();
	}

	@Override
	public void onPause() {
		super.onPause();
		// Release the MediaPlayer if going into background
		if (mp != null)
			mp.release();
	}
	
	@Override
	public void onBackPressed() {
		Intent myIntent = new Intent(this, Menu_Ejaan_FT.class);
		myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(myIntent);
	}
	
	public void home(View v){
		Intent myIntent = new Intent(this, Menu.class);
		myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(myIntent);
	}
	
}
